﻿var libs = new function () {
    this.showPopup = function (id) {
        var width = 500;
        var height = 300;
        var content = '';
        var html = '';
        $.ajax({
            type: "GET",
            url: "/ChartApi.ashx?t=detailsBetLog&id=" + id,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                $.each(data, function (i, item) {
                    console.log(item.line);
                    content += item.line;

                    html =
                    '<div id="Popup_Container" style="width:' + width + 'px; border:1px solid Gray; background:#fff;">' +
                    '<div  id="popup_nd">' +
                    '<div onclick="libs.CloseDialog();" style="position:absolute;right:15px; cursor:pointer;width:45px;height:50px;float:right;top:15px;"></div>' +
                    '<div id="temPopup">' + content +
                    '</div></div></div>' +
                    '<div onclick="libs.CloseDialog();"  id="overlay" class="overlay" style="width:100%; height:100%; position:fixed; top:0px;"></div>' +
                    '';
                    
                    $('BODY').append(html);

                    $('#popup_nd').css('width', width);
                    $('#popup_nd').css('height', height);
                    var leftOffset = ($(window).width() - width) / 2;
                    var topOffset = ($(window).height() - height) / 2 + $(window).scrollTop();
                    $('#Popup_Container').css('left', leftOffset + "px");
                    $('#Popup_Container').css('z-index', 1300);
                    $('#Popup_Container').css("top", topOffset + "px");
                    $('#Popup_Container').css('position', 'absolute');
                    $('#overlay').css('height', $(document).height());
                    $('#overlay').show();

                });
            }
        });
    };

    this.CloseDialog = function () {
        $('#Popup_Container').remove();
        $('#overlay').remove();
        $('.popup').remove();
        $('.overlay').remove();
    };
}